<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    var removeDuplicates = function (nums) {
        if (nums.length < 2) {
            return nums.length
        }
        let slow = 2
        let fast = 2
        while (fast < nums.length) {
            if (nums[slow - 2] !== nums[fast]) {
                nums[slow] = nums[fast]
                slow++
            }
            fast++
        }
        return slow
    };
    nums = [1,1,1,2,2,3]
    removeDuplicates(nums)
    console.log(nums);
    
</script>

</html>